import { catelist } from '../../../request/api';

// 封装一个接口类型
interface StateCate {
    cateList: Array<object>
}

const state = {
    cateList: []
}

const mutations = {
    CATE_LIST(state:StateCate,payload:any){
        state.cateList = payload
    }
}

const actions = {
    getCatelistActions(context: any) {
        catelist({
            istree: true
        }).then((res:any) => {
            console.log(res);            
            context.commit('CATE_LIST',res.list)
        })
    }
}

const getters = {
    // 将menuList反出去
    getCateList(state: StateCate) {
        return state.cateList
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}